// eslint-disable-next-line
import { role } from '@/core/icons'
import { BasicLayout, UserLayout } from '@/layouts'

const RouteView = {
    name: 'RouteView',
    render: h => h('router-view')
}

export const asyncRouterMap = [
    {
        path: '/',
        name: 'index',
        component: BasicLayout,
        meta: { title: '首页' },
        redirect: '/admin/list',
        children: [
            {
                path: '/admin',
                component: RouteView,
                redirect: '/admin/list',
                name: 'admin',
                meta: { title: '管理员管理', icon: role, keepAlive: true, permission: ['admin', 'adminList'] },
                children: [
                    {
                        path: '/admin/list',
                        name: 'adminList',
                        component: () => import('@/views/admin/list'),
                        meta: { title: '管理员列表', keepAlive: true, permission: ['adminList'] }
                    }
                ]
            },
            {
                path: '/role',
                component: RouteView,
                redirect: '/role/list',
                name: 'role',
                meta: { title: '权限管理', icon: role, keepAlive: true, permission: ['role', 'roleList'] },
                children: [
                    {
                        path: '/role/list',
                        name: 'roleList',
                        component: () => import('@/views/role/list'),
                        meta: { title: '角色列表', keepAlive: true, permission: ['roleList'] }
                    }
                ]
            },
            {
                path: '/order',
                component: RouteView,
                redirect: '/order/list',
                name: 'order',
                meta: { title: '订单管理', icon: role, keepAlive: true, permission: ['order', 'orderList'] },
                children: [
                    {
                        path: '/order/list',
                        name: 'orderList',
                        component: () => import('@/views/order/list'),
                        meta: { title: '订单列表', keepAlive: true, permission: ['orderList'] }
                    },
                    {
                        path: '/goods/list',
                        name: 'goodsList',
                        component: () => import('@/views/order/goods'),
                        meta: { title: '订单商品列表', keepAlive: true, permission: ['goodsList'] }
                    },
                    {
                        path: '/count/list',
                        name: 'countList',
                        component: () => import('@/views/order/count'),
                        meta: { title: '订单统计', keepAlive: true, permission: ['countList'] }
                    }
                ]
            },
            {
                path: '/delivery',
                component: RouteView,
                redirect: '/delivery/list',
                name: 'delivery',
                meta: { title: '配送管理', icon: role, keepAlive: true, permission: ['delivery', 'deliveryList'] },
                children: [
                    {
                        path: '/delivery/list',
                        name: 'deliveryList',
                        component: () => import('@/views/delivery/list'),
                        meta: { title: '骑手列表', keepAlive: true, permission: ['deliveryList'] }
                    },
                    {
                        path: '/delivery/setting',
                        name: 'deliverySetting',
                        component: () => import('@/views/delivery/setting'),
                        meta: { title: '配送设置', keepAlive: true, permission: ['deliverySetting'] }
                    }
                ]
            },
            {
                path: '/refrigerator',
                component: RouteView,
                redirect: '/refrigerator/list',
                name: 'refrigerator',
                meta: {
                    title: '冰箱管理',
                    icon: role,
                    keepAlive: true,
                    permission: ['refrigerator', 'refrigeratorList']
                },
                children: [
                    {
                        path: '/refrigerator/list',
                        name: 'refrigeratorList',
                        component: () => import('@/views/refrigerator/list'),
                        meta: { title: '冰箱列表', keepAlive: true, permission: ['refrigeratorList'] }
                    }
                ]
            },
            {
                path: '/size',
                component: RouteView,
                redirect: '/size/list',
                name: 'size',
                meta: { title: '尺寸管理', icon: role, keepAlive: true, permission: ['size', 'sizeList'] },
                children: [
                    {
                        path: '/size/list',
                        name: 'sizeList',
                        component: () => import('@/views/size/list'),
                        meta: { title: '尺寸列表', keepAlive: true, permission: ['sizeList'] }
                    }
                ]
            },
            {
                path: '/address',
                component: RouteView,
                redirect: '/address/list',
                name: 'size',
                meta: {
                    title: '配送中心地址管理',
                    icon: role,
                    keepAlive: true,
                    permission: ['address', 'addressList']
                },
                children: [
                    {
                        path: '/address/list',
                        name: 'addressList',
                        component: () => import('@/views/address/list'),
                        meta: { title: '配送中心地址列表', keepAlive: true, permission: ['addressList'] }
                    }
                ]
            }
        ]
    },
    {
        path: '*',
        redirect: '/404',
        hidden: true
    }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
    {
        path: '/user',
        component: UserLayout,
        redirect: '/user/login',
        hidden: true,
        children: [
            {
                path: 'login',
                name: 'login',
                component: () => import('@/views/user/Login')
            }
            // {
            //     path: 'register',
            //     name: 'register',
            //     component: () => import('@/views/user/Register')
            // },
            // {
            //     path: 'register-result',
            //     name: 'registerResult',
            //     component: () => import('@/views/user/RegisterResult')
            // },
            // {
            //     path: 'recover',
            //     name: 'recover',
            //     component: undefined
            // }
        ]
    }

    // {
    //     path: '/404',
    //     component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
    // }
]
